window.addEventListener('load',function(){
    // 第一个轮播
    (function(){
        var swiper = new Swiper(".my1", {
          spaceBetween: 0,
          centeredSlides: true,
          autoplay: {
            delay: 2500,
            disableOnInteraction: false,
          },
          navigation: {
            nextEl: ".swiper-button-next",
            prevEl: ".swiper-button-prev",
          },
        });
      })();
    //   第二个轮播
      (function(){
        var swiper = new Swiper(".my2", {
          spaceBetween: 0,
          centeredSlides: true,
          autoplay: {
            delay: 2500,
            disableOnInteraction: false,
          },
          navigation: {
            nextEl: ".swiper-button-next",
            prevEl: ".swiper-button-prev",
          },
        });
      })();
    //   免费公开课
    var free_btn = document.querySelectorAll('.free_btn');
    var free_content = document.querySelector('.free_content');
    for(var i = 0;i <free_btn.length;i++){
        free_btn[i].addEventListener('click',function(){
            for(var i =0;i<free_btn.length;i++){
                free_btn[i].className = 'free_btn';
            }
            this.className = 'free_btn change';
        })
    };
    // 点击按钮显示隐藏
    free_btn[0].addEventListener('click',function(){
        free_content.children[0].style.display = 'block';
        free_content.children[1].style.display = 'none';
        free_content.children[2].style.display = 'none';
    });
    free_btn[1].addEventListener('click',function(){
      free_content.children[0].style.display = 'none';
      free_content.children[1].style.display = 'block';
      free_content.children[2].style.display = 'none';
  })
    free_btn[2].addEventListener('click',function(){
      free_content.children[0].style.display = 'none';
      free_content.children[1].style.display = 'none';
      free_content.children[2].style.display = 'block';
  });
  // 第三个轮播
  (function(){
    var swiper = new Swiper(".my3", {
      slidesPerView: 4,
      spaceBetween: 15,
      autoplay: {
        delay: 2000,
        disableOnInteraction: false,
      }
    });
  })();
  // 学员就业轮播 手机端
  (function(){
    var swiper = new Swiper(".my3_app", {
      slidesPerView: 1,
      spaceBetween: 15,
      autoplay: {
        delay: 2000,
        disableOnInteraction: false,
      }
    });
  })();
  // 回到顶部 到free元素 显示隐藏
  var free = document.querySelector('.free');
  var freeTop = free.offsetTop;
  var service = document.querySelector('.service')
  window.addEventListener('scroll',function(){
    if(window.pageYOffset >= freeTop){
      service.style.opacity = '1';
    }else{
      service.style.opacity = '0';

    }
  });
  // 图片懒加载
  // (function(){
  //   lazyLoadInit({
  //     showTime:800,
  //     onLoadBackEnd:function(i,e){
  //         console.log("onLoadBackEnd:"+i);
  //     }
  //     ,onLoadBackStart:function(i,e){
  //         console.log("onLoadBackStart:"+i);
  //     }
  //   });
  // })();

  // 没有过度效果 解决方案利用锚链接 给html设置 scroll-behavior: smooth; 这个属性可以完全解决这个问题
  // service.addEventListener('click',function(){
    // window.scrollTo(0,0)
    // 第一次点击没有过度 效果不是很好
    // document.documentElement.style.scrollBehavior = 'smooth';
  // })
})